package com.skyz.wrap.adapter;

import android.view.View;
import android.view.ViewGroup;

import com.skyz.base.adapter.BaseRecyclerViewAdapter;
import com.skyz.wrap.R;

public abstract class WrapAdapter<DATA,
        VH extends BaseRecyclerViewAdapter.BaseViewHolder>
        extends BaseRecyclerViewAdapter<DATA, VH> {
    public Boolean isDisable = true;

    @Override
    protected int getInitLoadLayoutId() {
        return 0;
    }

    @Override
    protected int getNoDataLayoutId() {
        return R.layout.layout_no_data;
    }

    @Override
    protected int getLoadErrorLayoutId() {
        return 0;
    }

    public void setDisabled(Boolean disabled) {
        this.isDisable = disabled;
        notifyDataSetChanged();
    }

    protected void enableViews(View v, boolean enabled) {
        if (v instanceof ViewGroup) {
            ViewGroup vg = (ViewGroup) v;
            for (int i = 0; i < vg.getChildCount(); i++) {
                enableViews(vg.getChildAt(i), enabled);
            }
        }
        v.setEnabled(enabled);
    }
}
